package org.zxl.springbootdemo.mybatis.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.zxl.springbootdemo.mybatis.mapper.ZqhDiaryMapper;
import org.zxl.springbootdemo.mybatis.entity.ZqhDiary;

import java.util.List;

@Service
public class ZqhService {
    @Autowired
    private ZqhDiaryMapper zqhDiaryMapper;

    public void insert(ZqhDiary zqhDiary){
        zqhDiaryMapper.insert(zqhDiary);
    }

    @Transactional
    public void insert(List<ZqhDiary> zqhDiarys)
    {
        zqhDiarys.stream().forEach(zqh -> { zqhDiaryMapper.insert(zqh);});
    }

    public List<ZqhDiary> selectAll(){
        return zqhDiaryMapper.selectAll();
    }
}
